package org.jef.core.mask;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.Collection;

/**
 * @program: jef-cloud
 * @description: 实体字段的值需要重新计算时
 * @author: Cheng Zhi
 * @create: 2024-10-02 19:46
 **/
public class EvalSerializer extends JsonSerializer<String> {

    public Eval eval;
    public EvalSerializer(Eval eval) {
        this.eval = eval;

    }

    @Override
    public void serialize(String value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException {

        // 转换
        String evalValue = EvalUtil.getEvalValue(eval, value, value);
        gen.writeString(evalValue);
    }

    @Override
    public Class<String> handledType() {
        return String.class;
    }
}
